## Define function that recodes to numeric, but watches out to coercion to not introduce NAs
colstonumeric <- function(df){
tryCatch({
df_num <- as.data.frame(
lapply(df,
function(x) { as.numeric(as.character(x))}))
},warning = function(stop_on_warning) {
message("Stoped the execution of numeric conversion: ", conditionMessage(stop_on_warning))
})
}
##
## Define function that reverse codes items
ReverseCode <- function(df, tonumeric = FALSE, min = NULL, max = NULL) {
if(tonumeric) df <- colstonumeric(df)
df <- (max + min) - df
}
##
## Define function that scores only rows with less than 10% NAs (returns NA if all or above threshold percentage of rows are NA); can reverse code if vector of column indexes and min, max are provided.
ScoreLikert <- function(df, napercent = .1, tonumeric = FALSE, reversecols = NULL, min = NULL, max = NULL) {
reverse_list <- list(reversecols = reversecols, min = min, max = max)
reverse_check <- !sapply(reverse_list, is.null)
# Recode to numeric, but watch out to coercion to not introduce NAs
colstonumeric <- function(df){
tryCatch({
df_num <- as.data.frame(
lapply(df,
function(x) { as.numeric(as.character(x))}))
},warning = function(stop_on_warning) {
message("Stoped the execution of numeric conversion: ", conditionMessage(stop_on_warning))
})
}
if(tonumeric) df <- colstonumeric(df)
if(all(reverse_check)){
df[ ,reversecols] <- (max + min) - df[ ,reversecols]
}else if(any(reverse_check)){
stop("Insuficient info for reversing. Please provide: ", paste(names(reverse_list)[!reverse_check], collapse = ", "))
}
ifelse(rowSums(is.na(df)) > ncol(df) * napercent,
NA,
rowSums(df, na.rm = TRUE) * NA ^ (rowSums(!is.na(df)) == 0)
)
}
#### Func t test si boxplot simplu
func_t_box <- function(df, ind, pre_var, post_var){
vars <- c(ind, pre_var, post_var) # to avoid new tidyverse error of ambiguity due to external vectos
df_modif <-
df %>%
dplyr::select(tidyselect::all_of(vars)) %>%
tidyr::drop_na() %>%
gather(tidyselect::all_of(pre_var), tidyselect::all_of(post_var), key = "Cond", value = "value") %>%
mutate_at(vars(c(1, 2)), as.factor) %>%
mutate(Cond = factor(Cond, levels = c(pre_var, post_var)))
stat_comp <- ggpubr::compare_means(value ~ Cond, data = df_modif, method = "t.test", paired = TRUE)
stat_comp2 <-
df_modif %>%
do(tidy(t.test(.$value ~ .$Cond,
paired = TRUE,
data=.)))
plot <-
ggpubr::ggpaired(df_modif, x = "Cond", y = "value", id = ind,
color = "Cond", line.color = "gray", line.size = 0.4,
palette = c("#00AFBB", "#FC4E07"), legend = "none") +
stat_summary(fun.data = mean_se, colour = "darkred") +
ggpubr::stat_compare_means(method = "t.test", paired = TRUE, label.x = as.numeric(df_modif$Cond)-0.4, label.y = max(df_modif$value)+0.5) +
ggpubr::stat_compare_means(method = "t.test", paired = TRUE, label = "p.signif", comparisons = list(c(pre_var, post_var)))
cat(paste0("#### ", pre_var, " ", post_var, "\n", "\n"))
print(stat_comp)
print(stat_comp2)
print(plot)
}# library(tidyverse)
# library(ggpubr)
# library(rstatix)
# library(broom)
# library(emmeans)
# library(rlang)
# Function ANCOVAPost
# Takes Long Data
ANCOVAPost_func <-
function(data, id_var,
time_var, pre_label, post_label,
value_var = scores, cond_var,
assum_check = TRUE, posthoc = TRUE,
p_adjust_method = "bonferroni"){
id_var_enq <- rlang::enquo(id_var)
id_var_name <- rlang::as_name(id_var_enq)
time_var_enq <- rlang::enquo(time_var)
time_var_name <- rlang::as_name(time_var_enq)
pre_var_enq <- rlang::enquo(pre_label)
pre_var_name <- rlang::as_name(pre_var_enq)
post_var_enq <- rlang::enquo(post_label)
post_var_name <- rlang::as_name(post_var_enq)
cond_var_enq <- rlang::enquo(cond_var)
cond_var_name <- rlang::as_name(cond_var_enq)
value_var_enq <- rlang::enquo(value_var)
value_var_name <- rlang::as_name(value_var_enq)
data_wider <-
data %>%
dplyr::select(!!id_var_enq, !!time_var_enq, !!cond_var_enq, !!value_var_enq) %>%
spread(key = time_var_name, value = value_var_name) # %>% # if need to compute change score statistics go from here
# mutate(difference = !!post_var_enq - !!pre_var_enq)
# Assumptions
if(assum_check){
cat("\n Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group) \n")
# Create a scatter plot between the covariate (i.e., pretest) and the outcome variable (i.e., posttest)
scatter_lin <-
ggscatter(data_wider, x = pre_var_name, y = post_var_name, color = cond_var_name,
add = "reg.line", title = "Linearity assumption") +
stat_regline_equation(aes(label = paste(..eq.label.., ..rr.label.., sep = "~~~~"), color = !!cond_var_enq))
cat("\n Homogeneity of regression slopes (interaction term is n.s.) \n")
data_wider %>%
anova_test(as.formula(paste0(post_var_name, " ~ ", cond_var_name, " * ", pre_var_name))) %>%
print()
cat("\n Normality of residuals (Model diagnostics & Shapiro Wilk) \n")
# Fit the model, the covariate goes first
model <-
lm(as.formula(paste0(post_var_name, " ~ ", cond_var_name, " + ", pre_var_name)),
data = data_wider)
cat("\n Inspect the model diagnostic metrics \n")
model.metrics <-
augment(model) %>%
dplyr::select(-.hat, -.sigma, -.fitted, -.se.fit) %>% # Remove details
print()
cat("\n Normality of residuals (Shapiro Wilk p>.05) \n")
shapiro_test(model.metrics$.resid) %>%
print()
cat("\n Homogeneity of variances (Levene’s test p>.05) \n")
model.metrics %>%
levene_test(as.formula(paste0(".resid", " ~ ", cond_var_name)) ) %>%
print()
cat("\n Outliers (needs to be 0) \n")
model.metrics %>%
filter(abs(.std.resid) > 3) %>%
as.data.frame() %>%
print()
}
cat("\n ANCOVAPost \n")
res_ancova <-
data_wider %>%
anova_test(as.formula(paste0(post_var_name, " ~ ", pre_var_name, " + ", cond_var_name))) # the covariate needs to be first term
get_anova_table(res_ancova) %>% print()
cat("\n Pairwise comparisons \n")
pwc <-
data_wider %>%
emmeans_test(as.formula(paste0(post_var_name, " ~ ", cond_var_name)),
covariate = !!pre_var_enq,
p.adjust.method = p_adjust_method)
pwc %>% print()
cat("\n Display the adjusted means of each group, also called as the estimated marginal means (emmeans) \n")
get_emmeans(pwc) %>% print()
# Visualization: line plots with p-values
pwc <-
pwc %>%
add_xy_position(x = cond_var_name, fun = "mean_se")
line_plot <-
ggline(get_emmeans(pwc), x = cond_var_name, y = "emmean") +
geom_errorbar(aes(ymin = conf.low, ymax = conf.high), width = 0.2) +
stat_pvalue_manual(pwc, hide.ns = TRUE, tip.length = FALSE) +
labs(subtitle = get_test_label(res_ancova, detailed = TRUE),
caption = get_pwc_label(pwc))
if(assum_check){
list(scatter_lin, line_plot)
}else{
line_plot
}
}
# ex.
# ANCOVAPost_func(new_anxiety, time_var = time, pre_label = pretest, post_label = posttest,
# value_var = scores, cond_var = group, assum_check = TRUE, p_adjust_method = "bonferroni")# library(tidyverse)
# library(ggpubr)
# library(rstatix)
# library(rlang)
# Define Function for Mixed Anova
tw_mixedANOVA_func <-
function(data, id_var, cond_var, time_var, value_var,
assum_check = TRUE, posthoc_sig_interac = FALSE, posthoc_ns_interac = FALSE,
p_adjust_method = "bonferroni"){
# input dataframe needs to have columns names diffrent from "variable" and "value" because it collides with rstatix::shapiro_test
id_var_enq <- rlang::enquo(id_var)
cond_var_enq <- rlang::enquo(cond_var)
cond_var_name <- rlang::as_name(cond_var_enq)
time_var_enq <- rlang::enquo(time_var)
time_var_name <- rlang::as_name(time_var_enq)
value_var_enq <- rlang::enquo(value_var)
value_var_name <- rlang::as_name(value_var_enq)
data <- # need to subset becuase of strange contrasts error in anova_test()
data %>%
dplyr::select(!!id_var_enq, !!time_var_enq, !!cond_var_enq, !!value_var_enq)
# Assumptions
if(assum_check){
cat("\n Outliers \n")
data %>%
dplyr::group_by(!!time_var_enq, !!cond_var_enq) %>%
rstatix::identify_outliers(!!value_var_enq) %>% # outliers (needs to be 0)
print()
cat("\n Normality assumption (p>.05) \n")
data %>%
dplyr::group_by(!!time_var_enq, !!cond_var_enq) %>%
rstatix::shapiro_test(!!value_var_enq) %>% # normality assumption (p>.05)
print()
qq_plot <-
ggpubr::ggqqplot(data = data, value_var_name, ggtheme = theme_bw(), title = "QQ Plot") +
ggplot2::facet_grid(vars(!!time_var_enq), vars(!!cond_var_enq), labeller = "label_both") # QQ plot
cat("\n Homogneity of variance assumption - Levene’s test (p>.05) \n")
data %>%
group_by(!!time_var_enq ) %>%
levene_test(as.formula(paste0(value_var_name, " ~ ", cond_var_name))) %>%
print()
cat("\n Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001) \n")
box_m(data = data[, value_var_name, drop = FALSE], group = data[, cond_var_name, drop = TRUE]) %>%
print
}
# Two-way rmANOVA - check for interaction (ex. F(2, 22) = 30.4, p < 0.0001)
cat("\n Two-way rmANOVA \n")
res_aov <-
anova_test(data = data, dv = !!value_var_enq, wid = !!id_var_enq, # automatically does sphericity Mauchly’s test
within = !!time_var_enq, between = !!cond_var_enq)
get_anova_table(res_aov) %>% # ges: Greenhouse-Geisser sphericity correction is automatically applied to factors violating the sphericity assumption
print()
# ------------------------------------------------------------------------
#- Procedure for a significant two-way interaction -
if(posthoc_sig_interac){
cat("\n Effect of group at each time point - One-way ANOVA\n")
one_way <-
data %>%
group_by(!!time_var_enq) %>%
anova_test(dv = !!value_var_enq, wid = !!id_var_enq, between = !!cond_var_enq) %>%
get_anova_table() %>%
adjust_pvalue(method = p_adjust_method)
one_way %>% print()
cat("\n Pairwise comparisons between group levels \n")
pwc <-
data %>%
group_by(!!time_var_enq) %>%
pairwise_t_test(as.formula(paste0(value_var_name, " ~ ", cond_var_name)),
p.adjust.method = p_adjust_method)
pwc %>% print()
cat("\n Effect of time at each level of exercises group - One-way ANOVA \n")
one_way2 <-
data %>%
group_by(!!cond_var_enq) %>%
anova_test(dv = !!value_var_enq, wid = !!id_var_enq, within = !!time_var_enq) %>%
get_anova_table() %>%
adjust_pvalue(method = p_adjust_method)
one_way2 %>% print()
cat("\n Pairwise comparisons between time points at each group levels (we have repeated measures by time) \n")
pwc2 <-
data %>%
group_by(!!cond_var_enq) %>%
pairwise_t_test(
as.formula(paste0(value_var_name, " ~ ", time_var_name)), # paste formula, not quosure
paired = TRUE,
p.adjust.method = p_adjust_method
)
pwc2 %>% print()
}
#- Procedure for non-significant two-way interaction-
# If the interaction is not significant, you need to interpret the main effects for each of the two variables: treatment and time.
if(posthoc_ns_interac){
cat("\n Comparisons for treatment variable \n")
pwc_cond <-
data %>%
pairwise_t_test(
as.formula(paste0(value_var_name, " ~ ", cond_var_name)), # paste formula, not quosure
paired = FALSE,
p.adjust.method = p_adjust_method
)
pwc_cond %>% print()
cat("\n Comparisons for time variable \n")
pwc_time <-
data %>%
pairwise_t_test(
as.formula(paste0(value_var_name, " ~ ", time_var_name)), # paste formula, not quosure
paired = TRUE,
p.adjust.method = p_adjust_method
)
pwc_time %>% print()
}
# Visualization
bx_plot <-
ggboxplot(data, x = time_var_name, y = value_var_name,
color = cond_var_name, palette = "jco")
pwc <-
pwc %>%
add_xy_position(x = time_var_name)
bx_plot <-
bx_plot +
stat_pvalue_manual(pwc, tip.length = 0, hide.ns = TRUE) +
labs(
subtitle = get_test_label(res_aov, detailed = TRUE),
caption = get_pwc_label(pwc)
)
if(assum_check){
list(qq_plot, bx_plot)
}else{
bx_plot
}
}
# ex. - run on long format
# tw_mixedANOVA_func(data = anxiety, id_var = id, cond_var = group, time_var = time, value_var = score,
# posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Read, Clean, Recode, Unite
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
## Read files
folder <- "C:/Users/Mihai/Desktop/R Notebooks/notebooks/M2-report"
file <- "DateM2 final.xlsx"
setwd(folder)
Data_pre <- rio::import(file.path(folder, file),
skip = 3, which = "M2 PRE")
Data_post <- rio::import(file.path(folder, file),
skip = 3, which = "M2 POST")
# PRE = colnames(Data_pre); POST = colnames(Data_post)
# cbind(PRE, POST) # "s1.7" var is missing form POST -- missmatch row 12
# # also missing "s2.7" and others
# index from "DateM2.xlsx"
# index_ryff_pre <- 94:135
# index_pss_pre <- 136:149
# index_ryff_post <- 94:135 - 5
# index_pss_post <- 136:149 - 5
index_ryff_pre <- 83:124
index_pss_pre <- 125:138
index_ryff_post <- 81:122
index_pss_post <- 123:136
colnames(Data_pre)[1] <- "ID"
colnames(Data_pre)[colnames(Data_pre) == "Stres pre"] <- "VAS_stress_pre"
colnames(Data_pre)[colnames(Data_pre) == "Stres post"] <- "VAS_stress_post"
colnames(Data_pre)[index_ryff_pre] <- sprintf("ryff_%01d", seq(1, 42))
colnames(Data_pre)[index_pss_pre] <- sprintf("pss_%01d", seq(1, 14))
Data_pre <-
Data_pre %>%
drop_na(ID) %>%
dplyr::mutate_if(is.character, list(~dplyr::na_if(., "na")))
Data_pre[index_ryff_pre] <- colstonumeric(Data_pre[index_ryff_pre])
Data_pre$pss_8[Data_pre$pss_8 == "++++++"] <- NA # typo
Data_pre[index_pss_pre] <- colstonumeric(Data_pre[index_pss_pre])
colnames(Data_post)[1] <- "ID"
colnames(Data_post)[colnames(Data_post) == "Stres pre"] <- "VAS_stress_pre"
colnames(Data_post)[colnames(Data_post) == "Stres post"] <- "VAS_stress_post"
colnames(Data_post)[index_ryff_post] <- sprintf("ryff_%01d", seq(1, 42))
colnames(Data_post)[index_pss_post] <- sprintf("pss_%01d", seq(1, 14))
Data_post <-
Data_post %>%
dplyr::mutate_if(is.character, list(~dplyr::na_if(., "na")))
Data_post[index_ryff_post] <- colstonumeric(Data_post[index_ryff_post])
Data_post[index_pss_post] <- colstonumeric(Data_post[index_pss_post])
# typos
# check_numeric <- as.data.frame(sapply(Data_pre[index_pss_pre], varhandle::check.numeric))
# sapply(check_numeric, function(x) length(which(!x)))
colnames(Data_pre)[colnames(Data_pre) == "s1.1."] <- "s1.1"
colnames(Data_post)[colnames(Data_post) == "s1.1."] <- "s1.1"
Data_post$s2.10[which(Data_post$s2.10 == ".")] <- NA
Data_post$s2.10 <- as.numeric(Data_post$s2.10)
Data_post$s3.16[which(Data_post$s3.16 == "kq")] <- NA
Data_post$s3.16 <- as.numeric(Data_post$s3.16)## PSS-SF 14 (likert 0-4)
# Items 4, 5, 6, 7, 9, 10, and 13 are scored in reverse direction.
indexitem_revPSS <- c(4, 5, 6, 7, 9, 10, 13)
Data_pre[, index_pss_pre][indexitem_revPSS] <- ReverseCode(Data_pre[, index_pss_pre][indexitem_revPSS], tonumeric = FALSE, min = 0, max = 4)
Data_post[, index_pss_post][indexitem_revPSS] <- ReverseCode(Data_post[, index_pss_post][indexitem_revPSS], tonumeric = FALSE, min = 0, max = 4)
Data_pre$PSS <- ScoreLikert(Data_pre[, index_pss_pre], napercent = .4)
Data_post$PSS <- ScoreLikert(Data_post[, index_pss_post], napercent = .4)
## Ryff (likert 1-6)
# Recode negative phrased items: 3,5,10,13,14,15,16,17,18,19,23,26,27,30,31,32,34,36,39,41.
# Autonomy: 1,7,13,19,25,31,37
# Environmental mastery: 2,8,14,20,26,32,38
# Personal Growth: 3,9,15,21,27,33,39
# Positive Relations: 4,10,16,22,28,34,40
# Purpose in life: 5,11,17,23,29,35,41
# Self-acceptance: 6,12,18,24,30,36,42
indexitem_revRYFF <- c(3,5,10,13,14,15,16,17,18,19,23,26,27,30,31,32,34,36,39,41)
Data_pre[, index_ryff_pre][indexitem_revRYFF] <- ReverseCode(Data_pre[, index_ryff_pre][indexitem_revRYFF], tonumeric = FALSE, min = 1, max = 6)
Data_post[, index_ryff_post][indexitem_revRYFF] <- ReverseCode(Data_post[, index_ryff_post][indexitem_revRYFF], tonumeric = FALSE, min = 1, max = 6)
indexitem_Auto <- c(1,7,13,19,25,31,37)
indexitem_EnvM <- c(2,8,14,20,26,32,38)
indexitem_PersG <- c(3,9,15,21,27,33,39)
indexitem_PosRel <- c(4,10,16,22,28,34,40)
indexitem_PurLif <- c(5,11,17,23,29,35,41)
indexitem_SelfAc <- c(6,12,18,24,30,36,42)
Data_pre$Auto <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_Auto], napercent = .4)
Data_pre$EnvM <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_EnvM], napercent = .4)
Data_pre$PersG <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_PersG], napercent = .4)
Data_pre$PosRel <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_PosRel], napercent = .4)
Data_pre$PurLif <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_PurLif], napercent = .4)
Data_pre$SelfAc <- ScoreLikert(Data_pre[, index_ryff_pre][indexitem_SelfAc], napercent = .4)
Data_post$Auto <- ScoreLikert(Data_post[, index_ryff_post][indexitem_Auto], napercent = .4)
Data_post$EnvM <- ScoreLikert(Data_post[, index_ryff_post][indexitem_EnvM], napercent = .4)
Data_post$PersG <- ScoreLikert(Data_post[, index_ryff_post][indexitem_PersG], napercent = .4)
Data_post$PosRel <- ScoreLikert(Data_post[, index_ryff_post][indexitem_PosRel], napercent = .4)
Data_post$PurLif <- ScoreLikert(Data_post[, index_ryff_post][indexitem_PurLif], napercent = .4)
Data_post$SelfAc <- ScoreLikert(Data_post[, index_ryff_post][indexitem_SelfAc], napercent = .4)
## Save Scores
# rio::export(Data_pre[, c(1, 150:156)])
# rio::export(Data_post[, c(1, 149:155)])
# nlastcol <- 7
# rio::export(list(PRE = Data_pre[, c(1, (ncol(Data_pre)-nlastcol+1):ncol(Data_pre))], POST = Data_post[, c(1, (ncol(Data_post)-nlastcol+1):ncol(Data_post))]),
# "M2 PSS Ryff final.xlsx")
Data_pre$S1_Mean <- rowMeans(Data_pre[, sprintf("s1.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_pre[, grep("s1.", colnames(Data_pre))]
Data_pre$S2_Mean <- rowMeans(Data_pre[, sprintf("s2.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_pre[, grep("s2.", colnames(Data_pre))]
Data_pre$S3_Mean <- rowMeans(Data_pre[, sprintf("s3.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_pre[, grep("s3.", colnames(Data_pre))]
Data_post$S1_Mean <- rowMeans(Data_post[, sprintf("s1.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_post[, grep("s1.", colnames(Data_post))]
Data_post$S2_Mean <- rowMeans(Data_post[, sprintf("s2.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_post[, grep("s2.", colnames(Data_post))]
Data_post$S3_Mean <- rowMeans(Data_post[, sprintf("s3.%d", c(1:6, 8:16))], na.rm = TRUE) # Data_post[, grep("s3.", colnames(Data_post))]tr_ids <- paste0(c(1, 2, 4, 5, 6, 10, 13, 14, 15, 16, 24, 25, 26, 32, 34, 35, 39, 40, 42, 46, 47, 48, 51, 53, 59, 60, 62, 63, 64), " M2")
ctrl_ids <- paste0(c(3, 7, 8, 9, 11, 12, 17, 18, 19, 20, 21, 22, 23, 27, 28, 30, 33, 36, 37, 38, 41, 43, 45, 49, 52, 54, 55, 56, 57, 58), " M2")
# Subj from TR: Data_pre[which(Data_pre$ID %in% tr_ids),]
# Subj from CTRL: Data_pre[which(Data_pre$ID %in% ctrl_ids),]
Data_pre$Cond <- dplyr::case_when(Data_pre$ID %in% tr_ids ~ "TR",
Data_pre$ID %in% ctrl_ids ~ "CTRL",
TRUE ~ NA_character_)
Data_post$Cond <- dplyr::case_when(Data_post$ID %in% tr_ids ~ "TR",
Data_post$ID %in% ctrl_ids ~ "CTRL",
TRUE ~ NA_character_)## Number of subjects in pre
## Number of subjects in post
Data_pre$PrePost <- rep("Pre", nrow(Data_pre))
Data_post$PrePost <- rep("Post", nrow(Data_post))
Data_pre_scales <- Data_pre[, c("ID",
"VAS_stress_pre", "VAS_stress_post", "PSS",
"Auto", "EnvM", "PersG", "PosRel", "PurLif", "SelfAc", "S1_Mean", "S2_Mean", "S3_Mean",
"PrePost", "Cond")]
Data_post_scales <- Data_post[, c("ID",
"VAS_stress_pre", "VAS_stress_post", "PSS",
"Auto", "EnvM", "PersG", "PosRel", "PurLif", "SelfAc", "S1_Mean", "S2_Mean", "S3_Mean",
"PrePost", "Cond")]
Data_unif_long <- rbind(Data_pre_scales, Data_post_scales)
Data_unif_wide <-
Data_unif_long %>%
tidyr::pivot_wider(names_from = PrePost, values_from = c(VAS_stress_pre, VAS_stress_post, PSS, Auto, EnvM, PersG, PosRel, PurLif, SelfAc, S1_Mean, S2_Mean, S3_Mean))
Data_unif_long <-
Data_unif_long %>%
dplyr::mutate(ID = as.factor(ID),
Cond = as.factor(Cond),
PrePost = as.factor(PrePost)) %>%
dplyr::mutate(Vas_Diff = VAS_stress_post - VAS_stress_pre,
Vas_Mean = rowMeans(dplyr::select(.data = ., VAS_stress_post, VAS_stress_pre), na.rm = TRUE))# rmn_order_ids <- c(1, 14, 13, 6, 4, 5, 10, 15, 2, 16, 42, 34, 24, 25, 26, 35, 39, 40, 32, 59, 53, 64, 46, 47, 62, 63, 48, 51, 60,
# 8, 20, 12, 18, 9, 17, 19, 7, 3, 43, 41, 27, 23, 38, 22, 33, 28, 30, 21, 37, 49, 56, 58, 57, 52, 45, 55, 54)
# rmn_order_ids <- paste0(rmn_order_ids, " M2")
#
# RMN_df <- Data_unif_wide [match(rmn_order_ids, Data_unif_wide $ID),] # only 57 subjs for RMN
#
# rio::export(RMN_df, "RMN ordered M2.xlsx")cat("### PSS")
func_t_box(Data_unif_wide, "ID", "PSS_Pre", "PSS_Post")
cat("### Ryff")
func_t_box(Data_unif_wide, "ID", "Auto_Pre", "Auto_Post")
func_t_box(Data_unif_wide, "ID", "EnvM_Pre", "EnvM_Post")
func_t_box(Data_unif_wide, "ID", "PersG_Pre", "PersG_Post")
func_t_box(Data_unif_wide, "ID", "PosRel_Pre", "PosRel_Post")
func_t_box(Data_unif_wide, "ID", "PurLif_Pre", "PurLif_Post")
func_t_box(Data_unif_wide, "ID", "SelfAc_Pre", "SelfAc_Post")
cat("### Memory Scales")
func_t_box(Data_unif_wide, "ID", "S1_Mean_Pre", "S1_Mean_Post")
func_t_box(Data_unif_wide, "ID", "S2_Mean_Pre", "S2_Mean_Post")
func_t_box(Data_unif_wide, "ID", "S3_Mean_Pre", "S3_Mean_Post")–>
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = PSS, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.012 0.914000000 0.000215 2 Pre 1 55 33.434 0.000000361 * 0.378000 3 Cond:Pre 1 55 2.739 0.104000000 0.047000
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 32.428 0.000000475 * 0.367000 2 Cond 1 56 0.011 0.915000000 0.000205
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = Auto, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.0410000 0.84100000000000 0.00073700 2 Pre 1 55 74.0980000 0.00000000000901 * 0.57400000 3 Cond:Pre 1 55 0.0000569 0.99400000000000 0.00000104
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 75.445 0.00000000000583 * 0.574000 2 Cond 1 56 0.041 0.84000000000000 0.000737
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = EnvM, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.018 0.895000000 0.000321 2 Pre 1 55 34.023 0.000000299 * 0.382000 3 Cond:Pre 1 55 3.189 0.080000000 0.055000
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 32.743 0.000000429 * 0.369000 2 Cond 1 56 0.017 0.897000000 0.000303
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = PersG, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.053 0.81800000 0.000968 2 Pre 1 55 29.116 0.00000149 * 0.346000 3 Cond:Pre 1 55 0.731 0.39600000 0.013000
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 29.257 0.00000136 * 0.343000 2 Cond 1 56 0.054 0.81800000 0.000955
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = PosRel, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.092 0.7620000000000 0.002 2 Pre 1 55 64.079 0.0000000000856 * 0.538 3 Cond:Pre 1 55 1.048 0.3110000000000 0.019
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 64.024 0.0000000000769 * 0.533 2 Cond 1 56 0.092 0.7620000000000 0.002
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = PurLif, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.2230000 0.639000000 0.004000000 2 Pre 1 55 37.4200000 0.000000104 * 0.405000000 3 Cond:Pre 1 55 0.0000161 0.997000000 0.000000293
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 38.101 0.0000000795 * 0.405 2 Cond 1 56 0.227 0.6360000000 0.004
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = SelfAc, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.005 0.9430000000000 0.0000941 2 Pre 1 55 69.887 0.0000000000227 * 0.5600000 3 Cond:Pre 1 55 1.004 0.3210000000000 0.0180000
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 69.881 0.0000000000199 * 0.5550000 2 Cond 1 56 0.005 0.9430000000000 0.0000924
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = S1_Mean, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.024 0.8780000000000 0.000431 2 Pre 1 55 72.493 0.0000000000128 * 0.569000 3 Cond:Pre 1 55 0.022 0.8830000000000 0.000400
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 73.781 0.00000000000836 * 0.569000 2 Cond 1 56 0.024 0.87700000000000 0.000431
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = S2_Mean, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 2.077 0.15500000000000 0.036 2 Pre 1 55 74.964 0.00000000000748 * 0.577 3 Cond:Pre 1 55 1.310 0.25700000000000 0.023
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 74.551 0.00000000000707 * 0.571 2 Cond 1 56 2.066 0.15600000000000 0.036
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = S3_Mean, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 3.145 0.082000000000000 0.054 2 Pre 1 55 93.246 0.000000000000192 * 0.629 3 Cond:Pre 1 55 0.153 0.697000000000000 0.003
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 94.678 0.000000000000122 * 0.628 2 Cond 1 56 3.193 0.079000000000000 0.054
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = Vas_Diff, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 53 0.362 0.550 0.007 2 Pre 1 53 9.515 0.003 * 0.152 3 Cond:Pre 1 53 1.008 0.320 0.019
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 54 9.514 0.003 * 0.150 2 Cond 1 54 0.362 0.550 0.007
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
ANCOVAPost_func(data = Data_unif_long, id_var = ID, time_var = PrePost, pre_label = Pre, post_label = Post,
value_var = Vas_Mean, cond_var = Cond, assum_check = TRUE, p_adjust_method = "bonferroni")Linearity assumptionLinearity assumption (linear relationship between pre-test and post-test for each group)
Homogeneity of regression slopes (interaction term is n.s.) ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 0.022 0.884000 0.000392 2 Pre 1 55 15.386 0.000245 * 0.219000 3 Cond:Pre 1 55 0.257 0.614000 0.005000
Normality of residuals (Model diagnostics & Shapiro Wilk)
Inspect the model diagnostic metrics
Normality of residuals (Shapiro Wilk p>.05)
Homogeneity of variances (Levene’s test p>.05)
Outliers (needs to be 0)
ANCOVAPost ANOVA Table (type II tests)
Effect DFn DFd F p p<.05 ges 1 Pre 1 56 15.593 0.000222 * 0.21800 2 Cond 1 56 0.022 0.883000 0.00039
Pairwise comparisons
Display the adjusted means of each group, also called as the estimated marginal means (emmeans)
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = PSS, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.918 0.342 0.013000 2 PrePost 1 57 1.092 0.300 0.004000 3 Cond:PrePost 1 57 0.229 0.634 0.000801
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = Auto, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.513 0.477 0.00800000 2 PrePost 1 57 0.493 0.485 0.00100000 3 Cond:PrePost 1 57 0.003 0.954 0.00000739
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = EnvM, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.227 0.636 0.003000 2 PrePost 1 57 0.932 0.338 0.003000 3 Cond:PrePost 1 57 0.099 0.754 0.000346
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = PersG, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.134 0.716 0.0020000 2 PrePost 1 57 1.153 0.287 0.0040000 3 Cond:PrePost 1 57 0.014 0.908 0.0000496
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = PosRel, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.037 0.847 0.000563 2 PrePost 1 57 0.236 0.629 0.000584 3 Cond:PrePost 1 57 0.124 0.726 0.000308
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = PurLif, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.678 0.414 0.010000 2 PrePost 1 57 0.286 0.595 0.000916 3 Cond:PrePost 1 57 0.042 0.838 0.000134
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = SelfAc, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 1.128 0.293 0.017000 2 PrePost 1 57 0.960 0.331 0.002000 3 Cond:PrePost 1 57 0.205 0.653 0.000458
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = S1_Mean, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 2.845 0.097 0.042000 2 PrePost 1 57 11.041 0.002 * 0.023000 3 Cond:PrePost 1 57 0.118 0.732 0.000256
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = S2_Mean, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 2.952 0.0910000 0.043 2 PrePost 1 57 17.549 0.0000983 * 0.037 3 Cond:PrePost 1 57 1.569 0.2150000 0.003
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = S3_Mean, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 1.267 0.265 0.019 2 PrePost 1 57 3.754 0.058 0.007 3 Cond:PrePost 1 57 1.881 0.176 0.003
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = Vas_Diff, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 55 1.01900 0.317 0.013000000 2 PrePost 1 55 9.60500 0.003 * 0.051000000 3 Cond:PrePost 1 55 0.00007 0.993 0.000000391
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
tw_mixedANOVA_func(data = Data_unif_long, id_var = ID, cond_var = Cond, time_var = PrePost,
value_var = Vas_Mean, posthoc_sig_interac = TRUE, posthoc_ns_interac = TRUE)Outliers
Normality assumption (p>.05)
Homogneity of variance assumption - Levene’s test (p>.05)
Homogeneity of covariances assumption - Box’s test of equality of covariance matrices (p>.001)
Two-way rmANOVA ANOVA Table (type III tests)
Effect DFn DFd F p p<.05 ges
1 Cond 1 57 0.459 0.501 0.006000 2 PrePost 1 57 0.379 0.541 0.002000 3 Cond:PrePost 1 57 0.029 0.866 0.000136
Effect of group at each time point - One-way ANOVA
Pairwise comparisons between group levels
Effect of time at each level of exercises group - One-way ANOVA
Pairwise comparisons between time points at each group levels (we have repeated measures by time)
Comparisons for treatment variable
Comparisons for time variable
[[1]]
[[2]]
R version 3.6.1 (2019-07-05)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 8.1 x64 (build 9600)
Matrix products: default
locale:
[1] LC_COLLATE=Romanian_Romania.1250 LC_CTYPE=Romanian_Romania.1250 LC_MONETARY=Romanian_Romania.1250 LC_NUMERIC=C
[5] LC_TIME=Romanian_Romania.1250
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rlang_0.4.6 emmeans_1.4.5 rio_0.5.16 scales_1.1.0 ggpubr_0.2.5 magrittr_1.5
[7] tadaatoolbox_0.16.1 summarytools_0.8.8 rstatix_0.5.0 broom_0.5.6 PerformanceAnalytics_1.5.2 xts_0.11-2
[13] zoo_1.8-4 psych_1.9.12.31 forcats_0.5.0 stringr_1.4.0 dplyr_0.8.5 purrr_0.3.3
[19] readr_1.3.1 tidyr_1.0.2 tibble_3.0.0 ggplot2_3.3.0 tidyverse_1.3.0 papaja_0.1.0.9842
[25] pacman_0.5.1
loaded via a namespace (and not attached):
[1] TH.data_1.0-9 colorspace_1.4-1 ggsignif_0.4.0 pryr_0.1.4 ellipsis_0.3.0 estimability_1.3 fs_1.4.1 rstudioapi_0.11
[9] farver_2.0.3 fansi_0.4.1 mvtnorm_1.1-0 lubridate_1.7.4 xml2_1.3.1 codetools_0.2-16 splines_3.6.1 mnormt_1.5-6
[17] knitr_1.28 pixiedust_0.8.6 polynom_1.3-9 jsonlite_1.6.1 dbplyr_1.4.3 compiler_3.6.1 httr_1.4.1 backports_1.1.6
[25] assertthat_0.2.1 Matrix_1.2-17 cli_2.0.2 htmltools_0.4.0 tools_3.6.1 coda_0.19-2 gtable_0.3.0 glue_1.4.0
[33] Rcpp_1.0.4.6 carData_3.0-2 cellranger_1.1.0 vctrs_0.2.4 nlme_3.1-140 xfun_0.13 openxlsx_4.1.0 rvest_0.3.5
[41] lifecycle_0.2.0 MASS_7.3-51.4 hms_0.5.3 parallel_3.6.1 sandwich_2.5-0 expm_0.999-3 pwr_1.2-2 curl_4.3
[49] gridExtra_2.3 pander_0.6.3 stringi_1.4.6 nortest_1.0-4 boot_1.3-22 zip_1.0.0 pkgconfig_2.0.3 matrixStats_0.54.0
[57] bitops_1.0-6 lattice_0.20-38 labeling_0.3 rapportools_1.0 tidyselect_1.0.0 ggsci_2.9 plyr_1.8.6 R6_2.4.1
[65] DescTools_0.99.34 generics_0.0.2 multcomp_1.4-8 DBI_1.0.0 pillar_1.4.3 haven_2.2.0 foreign_0.8-71 withr_2.1.2
[73] mgcv_1.8-28 survival_2.44-1.1 abind_1.4-5 RCurl_1.95-4.11 modelr_0.1.6 crayon_1.3.4 car_3.0-7 viridis_0.5.1
[81] grid_3.6.1 readxl_1.3.1 data.table_1.12.8 reprex_0.3.0 digest_0.6.25 xtable_1.8-4 munsell_0.5.0 viridisLite_0.3.0
[89] quadprog_1.5-5
A work by Claudiu Papasteri